package BehavioralPattern.Strategy.StrategyEnum;

/**
 * @Classname : SaleEnum
 * @Description : 策略枚举
 * @Author : chentianyu
 * @Date 2023/2/26 11:15
 */


public enum SaleEnum {

    NEW_CUSTOMER_SALE(1, "新顾客原价出售：%.2f 元\n", 1),
    OLD_CUSTOMER_SALE(2, "老顾客九折出售：%.2f 元\n", 0.9),
    OFF_SEASON_SALE(3, "淡季八折抛售：%.2f 元\n", 0.8);

    private int code;
    private String name;
    private double discount;

    // 注意枚举构造函数不允许公开
    SaleEnum(int code, String name, double discount) {
        this.code = code;
        this.name = name;
        this.discount = discount;
    }

    public void sell(double price) {
        System.out.printf(this.name, this.discount * price);
    }
}
